<template>
    <div id="dialog" class="wrapper">
        <div class="close-button">
            <span></span>
            <el-button :icon="Close" circle @click="mapStore.leftMenu.visible = false" />
        </div>
        <dl class="menu">
            <dt>视频监控</dt>
            <dd>
                <el-button plain>电子地图</el-button>
                <el-button plain>实时预览</el-button>
                <el-button plain>预览回放</el-button>
            </dd>
            <dt>查询中心</dt>
            <dd>
                <el-button plain>一人一档</el-button>
                <el-button plain>视图检索</el-button>
                <el-button plain>身份核验</el-button>
            </dd>
            <dt>布控预警</dt>
            <dd>
                <el-button plain>人像库管理</el-button>
                <el-button plain>布控任务管理</el-button>
                <el-button plain>审核管理</el-button>
                <el-button plain>预警中心</el-button>
            </dd>
            <dt>智能任务</dt>
            <dd>
                <el-button plain>工单流配置</el-button>
                <el-button plain>工单任务处理</el-button>
            </dd>
            <dt>数据看板</dt>
            <dd>
                <el-button plain>未成年人概览</el-button>
                <el-button plain>未保监控大屏</el-button>
            </dd>
            <dt>系统管理</dt>
            <dd>
                <el-button plain>用户管理</el-button>
                <el-button plain>日志管理</el-button>
                <el-button plain>字典管理</el-button>
            </dd>
        </dl>
    </div>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
import { Close } from "@element-plus/icons-vue";
import pinia from "@/store/pinia.js";
import { useStore } from "@/store/index.js";
const mapStore = useStore(pinia);

onMounted(() => {
    const dialog = document.getElementById('dialog');
    let offsetX, offsetY;
    dialog.addEventListener('mousedown', function (e) {
        offsetX = e.offsetX;
        offsetY = e.offsetY;
        document.addEventListener('mousemove', onMouseMove);
        document.addEventListener('mouseup', onMouseUp);
    });
    function onMouseMove(e) {
        dialog.style.left = (e.clientX - offsetX) + 'px';
        dialog.style.top = (e.clientY - offsetY) + 'px';
    }
    function onMouseUp(e) {
        document.removeEventListener('mousemove', onMouseMove);
        document.removeEventListener('mouseup', onMouseUp);
    }
})
</script>

<style lang='less' scoped>
@import url("./css/index.css");

.wrapper {
    width: 330px;
    height: 520px;
    background: #fff;
    border-radius: 5px;
    position: absolute;
    left: 10px;
    top: 110px;
    z-index: 999;
    box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, 0.04),
        0px 8px 20px rgba(0, 0, 0, 0.08);

    animation-name: modalopen;
    animation-duration: 0.2s;
}

.close-button {
    cursor: move;
}

.menu {
    padding-left: 10px;
    padding-right: 10px;
    margin: 0;
}

.menu dt {
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: bold;
}

.menu dt:nth-child(1) {
    margin-top: 0;
}

.menu dd {
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;

    .el-button {
        width: 100px !important;
        padding: 5px 0px !important;
        margin-left: 0 !important;
        font-size: 13px !important;
    }
}

/* 动画定义 */
@keyframes modalopen {
    0% {
        left: -360px;
        opacity: 0;
    }

    // 50% {
    //     left: -50px;
    //     opacity: 1;
    // }

    100% {
        left: 0;
        opacity: 1;
    }
}

@keyframes modalclose {
    0% {
        left: 0;
        opacity: 1;
    }

    // 50% {
    //     left: -50px;
    //     opacity: 1;
    // }

    100% {
        left: -100px;
        opacity: 0;
    }
}
</style>